VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00

by Uwe Mayer (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 28th February 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00000000-0000-0000-0000-000000000000} 2)

Rate Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00



    Dim strGuid As String
    Dim strMask As String
    Dim lngIndex As Long
    Dim blnResult As Boolean
    
    blnResult = True
    If IsNull(Guid) Then
        blnResult = False
    Else
        strMask = "{[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]" & _
                    "-[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" & _
                    "-[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" & _
                    "-[0-9A-F][0-9A-F][0-9A-F][0-9A-F]" & _
                    "-[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]}"
        
        strGuid = CStr(Guid)
        If Left(strGuid, 6) = "{guid " And Right(strGuid, 1) = "}" Then
            strGuid = Mid(strGuid, 7, Len(strGuid) - 7)
        End If
        If Not strGuid Like strMask Then
            blnResult = False
        End If
    End If
    IsGuid = blnResult
End Function


Download this snippet    Add to My Saved Code

Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00 Comments

No comments have been posted about Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00. Why not be the first to post a comment about Function IsGuid() is checking a string whether it is a valid Guid or not. Valid formats are: 1) {00.

Post your comment

Subject:
Message:
0/1000 characters